package com.yunze.system.service.impl.yunze;

import com.yunze.common.mapper.mysql.polling.YzCardPollingErrorGroupMapper;

import com.yunze.common.utils.yunze.ListMapUtils;
import com.yunze.common.utils.yunze.PageUtil;
import com.yunze.system.service.yunze.IYzCardPollingErrorGroupService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class YzCardPollingErrorGroupServiceImpl implements IYzCardPollingErrorGroupService {

    @Resource
    private YzCardPollingErrorGroupMapper yzCardPollingErrorGroupMapper;



    @Override
    public Map<String, Object> listGroup(Map map) {
        Map<String, Object> omp=new HashMap<String, Object>();
        Integer currenPage=map.get("pageNum")!=null?Integer.parseInt(map.get("pageNum").toString()):0;
        Integer pageSize=map.get("pageSize")!=null?Integer.parseInt(map.get("pageSize").toString()):10;
        Integer rowCount = yzCardPollingErrorGroupMapper.selMapCount(map);// mysql
//        Integer rowCount = tdbCardPollingErrorGroupMapper.selMapCount(map);  //tdengine

        rowCount=rowCount!=null?rowCount:0;
        PageUtil pu=new PageUtil(rowCount,currenPage , pageSize);//初始化分页工具类
        //数据打包
        map.put("StarRow", pu.getStarRow());
        map.put("PageSize", pu.getPageSize());
        omp.put("Pu", pu);

        omp.put("Data", yzCardPollingErrorGroupMapper.selMap(map)); //mysql
//        List<Map<String, Object>> maps = new ArrayList<>();
//        List<Map<String, Object>> selMap = tdbCardPollingErrorGroupMapper.selMap(map);
//        for (int i = 0; i < selMap.size(); i++) {
//            maps.add(selMap.get(i));
//        }
//        Map<String, Object> kmap1 = new HashMap<String, Object>();
//        kmap1.put("key","ts");
//       // List<Map<String, Object>> endMap = ListMapUtils.CZCUpdTsToString(maps);
//        List<Map<String, Object>> endMap = ListMapUtils.CZCUpdTimeStampToString(maps, kmap1);
//
//        Map<String, Object> kmap = new HashMap<String, Object>();
//        kmap.put("key","upd_date");
//        List<Map<String, Object>> endmap = ListMapUtils.CZCUpdTimeStampToString(endMap, kmap);
//        omp.put("Data", endmap); //tdengine

        return omp;
    }

    @Override
    public boolean del(Map map) {
        return yzCardPollingErrorGroupMapper.del(map)>0;
    }

    @Override
    public boolean upd(Map map) {
        return yzCardPollingErrorGroupMapper.updObj(map)>0;
    }

    @Override
    public boolean delArr(Map map) {
        return yzCardPollingErrorGroupMapper.delArr(map)>0;
    }

    @Override
    public boolean updArr(Map map) {
        return yzCardPollingErrorGroupMapper.updArr(map)>0;
    }
}
